﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using MINERP.DAL;
using MINERP.BLL.Statistics;
using MINERP.DAL.Statistics;

using FastReport;
using MINERP.COM;

namespace MINERP.Statistics.Forms
{
    public partial class FrmSalesmanAccountMove : Form
    {
        Report report1 = new Report();
        
        public FrmSalesmanAccountMove()
        {
            InitializeComponent();
        }

        private void FrmSalesmanAccountMove_Load(object sender, EventArgs e)
        {
            LinkSalesman();
            cmbOperationType.SelectedIndex = 0;
            DEStart.DateTime =DEEND.DateTime= DateTime.Now;

        }
        private void LinkSalesman()
        {
            SalesmanBLL sbll= new SalesmanBLL();
            cmbSalesman.Properties.DataSource = sbll.GetSalesmanList();
            cmbSalesman.Properties.DisplayMember = "SalesmanName";
            cmbSalesman.Properties.ValueMember = "SalesmanName";
            cmbSalesman.Refresh();
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            int operationType = -1;

            simpleButton1.Enabled = false;
            if (cmbSalesman.EditValue == null)
            {
                simpleButton1.Enabled = true;
                return;
            }

            switch (cmbOperationType.Text)
            {
                case "全部":
                    operationType = -1;
                    break;
                case "充值":
                    operationType =(int) CountOperationType.ChongZhi;
                    break;
                case "冲抵":
                    operationType = (int)CountOperationType.DiChong;
                    break;
                case "清零":
                    operationType = (int)CountOperationType.QingLing;
                    break;
                default :
                    operationType = -1;
                    break;
                 
            }
            this.Cursor = Cursors.WaitCursor;
            DataSet dsResult = ShopBalanceMoveDAL.GetSalesmanAccountRecord((string)cmbSalesman.EditValue, DEStart.DateTime.Date, DEEND.DateTime.Date.AddDays(1),operationType);
            dsResult.WriteXml(@"C:\Windows\xmldata\业务员帐户资金流动记录.xml", XmlWriteMode.WriteSchema);
            report1.Preview = previewControl1;
            report1.Load(Application.StartupPath + "\\Report\\业务员帐户资金流动记录.frx");
            report1.RegisterData(dsResult);
            previewControl1.Refresh();
            //previewControl1.Show();
            report1.Show();
            this.Cursor = Cursors.Default;
            simpleButton1.Enabled = true;

        }
    }
}
